<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>

<script>
test(function(t) {

    var ctx = document.createElement('canvas').getContext('2d');
    
    ctx.fillStyle = 'red';
    ctx.fillRect(0, 0, 1, 1);
    
    assert_equals(ctx.fillStyle, '#ff0000');
    var imageData = ctx.getImageData(0, 0, 2, 1);
    assert_array_equals(imageData.data.slice(0,4), [255, 0, 0, 255]);
    assert_array_equals(imageData.data.slice(4), [0, 0, 0, 0]);
    
    ctx.putImageData(imageData, 1, 1);
    imageData = ctx.getImageData(1, 1, 1, 1);
    assert_array_equals(imageData.data, [255, 0, 0, 255]);
    
    assert_equals(ctx.fillStyle, '#ff0000');
    
    ctx.fillRect(2, 2, 1, 1);
    data = ctx.getImageData(2, 2, 1, 1).data;
    assert_array_equals(data, [255, 0, 0, 255]);

}, "Test that the rendering context state is intact after a call to putImageData()");
</script>
